$(function() {
    $('.layui-plus').click(function() {
        layer_iframe('添加附近动态', 'edit');
    });
    window.page = 1;
    window.limit = 10;
    window.options = {
        id: 'data_table',
        elem: '.layui-table.data-table',
        url: location.pathname + location.search,
        where: {},
        page: {
            curr: 1
        },
        limits: [10, 25, 50, 100],
        done: function(res, curr, first) {
            if (!res.data && curr > 1) {
                window.options.page.curr = curr - 1;
                window.tableIns.reload(window.options);
            }
            window.options.page.curr = curr;
            window.page = curr;
            window.limit = res.limit;
        },
        cols: [
            [{
                title: '发布人编号',
                unresize: true,
                align: 'center',
                templet:function(d){
                    return '<div style="cursor:pointer;text-decoration:underline;color:#6590DC" lay-event="user" >'+d.number+'</div>';
                },
                width:'10%'
            }, {
                field: 'image',
                title: '图片',
                unresize: true,
                align: 'center',
                templet:function(d){
                    var str = '';
                    for(i= 0 ; i< d.image.length; i++){
                        str += '<img src="'+d.image[i]+'" width="60px" height="60px" style="margin:3px" data-url="'+d.image[i]+'" lay-event="fangda" title="点击放大">';
                    }
                    return str;
                },
                width:'26%'
            }, {
                field: 'title',
                title: '文字描述',
                unresize: true,
                align: 'center',
   
                width:'20%'
            }, {
                field: 'collect_num',
                title: '收藏量',
                unresize: true,
                align: 'center',

                width:'10%'
            }, {
                field: 'zan_num',
                title: '点赞量',
                unresize: true,
                align: 'center',
                width:'10%'
            }, {
                field: 'add_time',
                title: '发布时间',
                unresize: true,
                align: 'center',
                width:'12%'
            }, {
                title: '操作',
                unresize: true,
                align: 'center',
                toolbar: '#toolbar_normal',
                width:'12%'
            }]
        ],
    };
    window.tableIns = laytable.render(window.options);
    laytable.on('tool(data_table)', function(obj) {
        if (obj.event === 'edit') {
            layer_iframe('编辑附近动态', 'edit?id=' + obj.data.id);
        } else if (obj.event === 'del') {
            _ajax_update('确定删除该动态吗?', 'bz_nearby', obj.data.id, {
                status: 0
            });
        }else if (obj.event === 'user') {
            layer_iframe('会员信息', '/before/user/index?id=' + obj.data.user_id);

        }else if (obj.event == 'fangda') {
            $('.max-img').attr('src',$(this).attr('src'));
            $('.bg').show();
        }
    });
});
